package com.admin.model.dto;

import com.admin.model.base.BaseDto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.validation.constraints.*;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * (User)实体类
 *
 * @author makejava
 * @since 2021-01-31 19:19:28
 */
@ApiModel("用户实体类")
@Data
@EqualsAndHashCode(callSuper = true)
@AllArgsConstructor
@NoArgsConstructor
public class UserDto extends BaseDto implements Serializable {
    private static final long serialVersionUID = -91225182066461103L;

    /**
     * id
     */
    @NotNull(message = "用户id不能为空", groups = Update.class)
    @Null(message = "用户id必须为null", groups = Create.class)
    @ApiModelProperty("id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;
    /**
     * 姓名
     */
    @ApiModelProperty("姓名")
    @NotBlank(message = "姓名不能为空", groups = Create.class)
    private String name;
    /**
     * 用户名
     */
    @ApiModelProperty("用户名")
    @NotBlank(message = "用户名不能为空", groups = Create.class)
    private String username;
    /**
     * 密码
     */
    @JsonIgnore
    private String password;
    /**
     * 头像真实路径
     */
    @ApiModelProperty("头像真实路径")
    private String avatarPath;
    /**
     * 头像地址
     */
    @ApiModelProperty("头像地址")
    private String avatarName;
    /**
     * 性别：0:位置1:男，2:女
     */
    @ApiModelProperty("性别：1:男，2:女")
    private Integer sex;
    /**
     * 手机号
     */
    @ApiModelProperty("手机号")
    @Pattern(message = "手机号格式不正确", regexp = "^$|^1[3|4|5|7|8][0-9]{9}$")
    private String phone;
    /**
     * 邮箱
     */
    @ApiModelProperty("邮箱")
    @Email(message = "邮箱格式错误")
    private String email;
    /**
     * 状态：false:停用，true:启用
     */
    @ApiModelProperty("状态：false:停用，true:启用")
    //@Null(groups = {Create.class, Update.class})
    private Boolean enabled;
    /**
     * 修改密码的时间
     */
    @ApiModelProperty("修改密码的时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    // @Null(message = "修改密码的时间必须为null", groups = {Create.class, Update.class})
    private LocalDateTime pwdResetTime;
    /**
     * 账户有效期天数
     */
    @JsonIgnore
    private Integer expiredDays;

    /**
     * 用户锁定: false:停用，true:启用
     */
    @ApiModelProperty("户锁定：false:停用，true:启用")
    //@Null(groups = {Create.class, Update.class})
    private Boolean locked;

    /**
     * 用户角色
     */
    @ApiModelProperty("用户角色")
    private List<RoleDto> roles;
    /**
     * 部门
     */
    @ApiModelProperty("部门")
    private List<DeptDto> depts;
    /**
     * 岗位
     */
    @ApiModelProperty("岗位")
    private List<JobDto> jobs;

}